<?php 

function dateValid($date=null)
{
	//buat array nama hari dalam bahasa Indonesia dengan urutan 1-7
	$array_hari = array(1=>'Senin','Selasa','Rabu','Kamis','Jumat', 'Sabtu','Minggu');
	//buat array nama bulan dalam bahasa Indonesia dengan urutan 1-12
	$array_bulan = array(1=>'Januari','Februari','Maret', 'April', 'Mei', 'Juni','Juli','Agustus',
					'September','Oktober', 'November','Desember');
	
	if ($date == '0000-00-00' || $date == '1970-01-01' || $date == null ){
		return "";
	} else {
		//jika $date diisi, makan tanggal yang diformat adalah tanggal tersebut
		$date  = strtotime($date);
		$hari  = $array_hari[date('N',$date)];
		$tanggal = date ('j', $date);
		$bulan = $array_bulan[date('n',$date)];
		$tahun = date('Y',$date);
		$formatTanggal = $tanggal ." ". $bulan ." ". $tahun;
		return $formatTanggal;
	}
}


if(@$type!=="excel") { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Laporan Tender PQ</title>
<?php echo css_asset("printstyle.css"); ?>
</head>
<body>
<?php } else { ?>
<html xmlns:o="urn:schemas-microsoft-com:office:office"
                                       xmlns:x="urn:schemas-microsoft-com:office:excel"
                                        xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Laporan Tender PQ</title>
<style>
.table{
        border-collapse:collapse;      
}
</style>
<xml>
 <x:ExcelWorkbook>
  <x:ExcelWorksheets>
   <x:ExcelWorksheet>
    <x:Name>Sheet</x:Name>
    <x:WorksheetOptions>
     <x:Print>
        <x:Gridlines />
     </x:Print>
    </x:WorksheetOptions>
   </x:ExcelWorksheet>
  </x:ExcelWorksheets>
 </x:ExcelWorkbook>
</xml>
</head>
<body>
<?php } ?>
<table summary='Laporan Detail Jadwal' width="100%" class="print">
	<caption>Laporan Tender PQ</caption>
	<thead>
		<tr>
			<th scope='col' >No</th>
			<th scope='col' >Nama Kegiatan</th>
			<th scope='col' >NK (Pagu)</th>
			<th scope='col' >Pemasukan</th>
			<th scope='col' >Update Status</th>
		</tr>
	</thead>
	<tbody>
		<?php $i=0; foreach($data_print as $print) { $i++; ?>
			<tr>
				<td><?php echo $i; ?></td>
				<td><?php echo $print->jadwal_namaproyek; ?></td>
				<td style="text-align:right"><?php echo number_format($print->jadwal_pagu,0,",","."); ?></td>
				<td><?php echo dateValid($print->jadwal_tglpq); ?></td>
				<td><?php echo $print->jadwal_updatestatus; ?></td>
			</tr>
		<?php } ?>
	</tbody>
	<tfoot><tr><th scope='row'>Total</th><td colspan='4'><?php echo count($data_print); ?></td></tr></tfoot>
	</table>
</body>
</html>